namespace CSharpPro._1021;
public class Demo
{
    public void TestPrint()
    {
        UserTest userTest=new UserTestChild();
        userTest.M1();
        userTest.M2("测试消息");
        int result = userTest.M3(10, 20);
        Console.WriteLine($"M3 方法返回结果：{result}\n");

        // 测试接口实现类
        IUserService userService = new UserServiceImpl();
        userService.Add("姓名：张三，年龄：25");
        userService.Query(1);
        userService.Update(1, "姓名：张三，年龄：26");
        userService.Delete(1);
        
        Father father = new Father();
        father.Print();
        Child child = new Child();
        child.Print();
        Son son = new Son();
        son.Print();
        
        Console.WriteLine("-----------");
        //向上转型
        Father father2 = new Child();
        father2.Print();
        Father father3 = new Son();
        father3.Print();
        
        Student student = new Student();

        //在结尾打var 回车+回车
        int compare = student.Compare(10, 20, 30);
        Console.WriteLine(compare);

        //Convert.ToInt32()方法重载

        student.Id = Convert.ToInt32("123");
        Console.WriteLine(student.Id);

        student.Name = "张三";//赋值
        Console.WriteLine(student.Name);//获取值

    }
}